/*!
    \copyright  Copyright (c) 2019 - 2025 Qualcomm Technologies International, Ltd.
                All Rights Reserved.
                Qualcomm Technologies International, Ltd. Confidential and Proprietary.
    \file
    \ingroup    ui_indicator
    \brief      Kymera platform specific parts of the UI Prompts Indicator
*/

#include "ui_indicator_prompts.h"
#include "ui_indicator_private.h"
#include "ui_indicator.h"

#include <kymera.h>
#include <logging.h>
#include <stdlib.h>
#include <math.h>

extern ui_prompts_task_data_t the_prompts;

void UiPrompts_AudioSpecificInit(void)
{
    /* No platform specific initialisation is needed for Kymera. */
}

void UiIndicator_PromptAudioStart(rtime_t time_to_play, const ui_prompt_data_t *config, FILE_INDEX index)
{
    appKymeraPromptPlay(index, config->format, config->rate, time_to_play,
                        config->interruptible, ui_GetAudioResourceLockAddress(),
                        UI_KYMERA_RESOURCE_LOCKED);
}

void UiIndicator_PromptAudioStop(void)
{
    appKymeraTonePromptCancel();
    if (the_prompts.interrupting_prompt)
    {
        uiPrompts_HandleInterruptingPrompt();
    }
}

rtime_t UiIndicator_PromptAudioGetGraphSetupTimeMicroseconds(const ui_prompt_data_t *config)
{
    /* Factor in the propagation latency through the various buffers for the aux channel and the time to start the file source */
    rtime_t time_alloted_for_graph_setup;

    time_alloted_for_graph_setup = UI_SYNC_IND_AUDIO_SS_FIXED_DELAY;

    if (!Kymera_IsReadyForPrompt(config->format, config->rate))
    {
        time_alloted_for_graph_setup = rtime_add(time_alloted_for_graph_setup, UI_SYNC_IND_AUDIO_SS_CHAIN_CREATION_DELAY);
    }
    return time_alloted_for_graph_setup;
}
